using UnityEngine;
using Voodoo.Sauce.Core;
using Voodoo.Sauce.Internal.Extension;

namespace Voodoo.Sauce.Internal.Analytics
{
	public class DebugForcedCohort
	{
		public int index;

		private VoodooSettings _settings;

		public DebugForcedCohort()
		{
			index = 0;
		}

		public string GetCohort()
		{
			if (_settings == null)
			{
				_settings = VoodooSettings.Load();
			}
			string[] runningABTests = _settings.GetRunningABTests();
			if (index < 3)
			{
				return "Control";
			}
			return runningABTests[index - 3];
		}

		public bool HasForcedNoCohort()
		{
			return index == 1;
		}

		private bool IsNotEmpty()
		{
			return index > 0;
		}

		public bool IsDebugCohort()
		{
			if (Debug.isDebugBuild || Application.isEditor)
			{
				return IsNotEmpty();
			}
			return false;
		}
	}
}
